package nanocast.apps.creator.modules.mediaWindow
{
	import nanocast.apps.creator.modules.mediaWindow.common.MediaWindowAppConstants;
	import nanocast.apps.creator.modules.mediaWindow.controller.ApplicationStartupCommand;
	import nanocast.apps.creator.modules.mediaWindow.controller.LoadMediaXmlCommand;
	import nanocast.apps.creator.modules.mediaWindow.controller.RefreshMediaTileCommand;
	
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	import org.puremvc.as3.multicore.utilities.assetLoader.etypes.LoaderNotificationNames;
	
	
	public class MediaWindowFacade extends Facade
	{
		public static const STARTUP:String = "startup";
		
		public function MediaWindowFacade(key:String) 
		{
			super(key);
		}
		
		public static function getInstance(key:String):MediaWindowFacade
		{
			if(instanceMap[key] == null)
			{
				instanceMap[key] = new MediaWindowFacade(key);
			}
			
			return instanceMap[key] as MediaWindowFacade;	
		}
		
		override protected function initializeController():void
		{
			super.initializeController();
			
			registerCommand(STARTUP, ApplicationStartupCommand);
            registerCommand( MediaWindowAppConstants.LOAD_MEDIA_XML_COMMAND, LoadMediaXmlCommand );
			registerCommand(LoaderNotificationNames.QUE_COMPLETED, RefreshMediaTileCommand);
		}
		
		public function startup(app:MediaWindow):void
		{
			sendNotification(STARTUP, app);
			
			sendNotification(MediaWindowAppConstants.LOAD_MEDIA_XML_COMMAND);
		} 
	}
}